import cn.dao.dao.BillDao;
import cn.dao.dao.UserDao;
import cn.dao.entity.Provider;
import cn.dao.entity.UserInfo;
import cn.dao.entity.bill;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * Created by sunbin on 2017/7/14.
 */
public class text {
    String path= "mybatis-config.xml";
    InputStream is= Resources.getResourceAsStream(path);
    SqlSessionFactory factory=new SqlSessionFactoryBuilder().build(is);
    SqlSession session=factory.openSession();

    public text() throws IOException {
    }

    @Test
    public void Show(){
        UserDao mapper = session.getMapper(UserDao.class);
        UserInfo inf=mapper.isLogin("123456","123123");
        System.out.println(inf.getUserName());
    }
    @Test
    public void Showssss(){
        BillDao mapper = session.getMapper(BillDao.class);
              bill bill=new bill();
              bill.setId(4);
              bill.setProductName("111");
              bill.setBillCode("2");
              bill.setProductUnit("3");
              bill.setTotalPrice(200);
              bill.setProvider(1);
              bill.setProductCount(3);
              bill.setIsPayment(1);
            int num=  mapper.inserts(bill);
        System.out.println(num);

    }
    @Test
    public void Showsw(){
        BillDao mapper = session.getMapper(BillDao.class);

       int num=mapper.deletes(1);
        System.out.println(num);
    }
    @Test
    public void Shows(){
        BillDao mapper = session.getMapper(BillDao.class);

        List<bill> list=mapper.list(0,2,null,null,1);
        for (bill item:list
             ) {
            System.out.println(item.getCreationDate());
        }
    }
    @Test
        public void Showss() {
        BillDao mapper = session.getMapper(BillDao.class);
        List<Provider>list=mapper.listg();
        for (Provider item:list){
            System.out.println(item.getProName());
        }
    }
    @Test
    public void Showsss() {
        BillDao mapper = session.getMapper(BillDao.class);
       int num=mapper.count(null,null,null);
        System.out.println(num);
    }
}
